package com.winderinfo.yikaotianxia.ui.report;

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Button;

import com.winderinfo.yikaotianxia.R;
import com.winderinfo.yikaotianxia.core.base.BaseActivity;
import com.winderinfo.yikaotianxia.core.utils.LogUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ReportActivity extends BaseActivity {
    @BindView(R.id.pres_dan)
    RecyclerView presDan;
    @BindView(R.id.pres_duo)
    RecyclerView presDuo;
    @BindView(R.id.pres_but)
    Button presBut;
    private List<ReportBean.YkScoreBean.YkAnswerRecordsBean> dan;
    private List<ReportBean.YkScoreBean.YkAnswerRecordsBean> duo;
    private int id;

    @Override
    protected int initLayoutId() {
        return R.layout.activity_presentation;
    }

    @Override
    protected void initView() {

        ReportBean.YkScoreBean reoprt = (ReportBean.YkScoreBean) getIntent().getSerializableExtra("reoprt");
        id = getIntent().getIntExtra("id", 0);
        LogUtil.i("ssss", id + "");
        List<ReportBean.YkScoreBean.YkAnswerRecordsBean> ykAnswerRecords = reoprt.getYkAnswerRecords();
        dan = new ArrayList<>();
        duo = new ArrayList<>();
        for (int i = 0; i < ykAnswerRecords.size(); i++) {
            if (ykAnswerRecords.get(i).getTitleType().equals("1")) {
                dan.add(ykAnswerRecords.get(i));
            }
            if (ykAnswerRecords.get(i).getTitleType().equals("2")) {
                duo.add(ykAnswerRecords.get(i));
            }
        }
    }

    @Override
    protected void initData() {
        //单
        presDan.setLayoutManager(new GridLayoutManager(this, 5));
        ReportAdapter reportAdapter = new ReportAdapter(this, dan);
        presDan.setAdapter(reportAdapter);
        //多
        presDuo.setLayoutManager(new GridLayoutManager(this, 5));
        ReportAdapter reportAdaptera = new ReportAdapter(this, duo);
        presDuo.setAdapter(reportAdaptera);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.pres_but)
    public void onViewClicked() {
        Bundle bundle = new Bundle();
        bundle.putInt("id", id);
        openActivity(QuestionListActivity.class, bundle);
    }
}
